Page({
    data: {
        searchvalue: "",
        data: [],
        hiddendata: !0,
        hiddenName: !1
    },
    onLoad: function() {},
    search: function(a) {
        this.setData({
            searchvalue: a.detail.value
        });
    },
    matchsearchbutton: function() {
        var a = this, t = a.data.searchvalue, e = t.replace(/\*/g, "%");
        wx.showToast({
            title: "加载中",
            icon: "loading",
            duration: 5e3
        }), "*" == t ? wx.request({
            url: "https://www.yehamson.xyz/idiom/rand.php",
            data: {},
            success: function(t) {
                console.log(t.data), wx.hideToast(), wx.showModal({
                    title: "未指定",
                    content: "随机推荐10个成语",
                    showCancel: !1
                }), a.setData({
                    data: t.data,
                    hiddendata: !1,
                    hiddenName: !0
                });
            }
        }) : wx.request({
            url: "https://www.yehamson.xyz/idiom/search.php",
            data: {
                value: e
            },
            success: function(t) {
                null == t.data ? (wx.hideToast(), wx.showModal({
                    title: "出现问题了",
                    content: "查无此数据或格式错误",
                    showCancel: !1
                }), a.setData({
                    hiddenName: !1,
                    hiddendata: !0
                })) : (wx.hideToast(), a.setData({
                    data: t.data,
                    hiddenName: !0,
                    hiddendata: !1
                }));
            }
        });
    },
    vaguesearchbutton: function() {
        var a = this, t = a.data.searchvalue, e = t.replace(/\*/g, "%");
        wx.showToast({
            title: "加载中",
            icon: "loading",
            duration: 5e3
        }), "" == t ? wx.request({
            url: "https://www.yehamson.xyz/idiom/rand.php",
            data: {},
            success: function(t) {
                console.log(t.data), wx.hideToast(), wx.showModal({
                    title: "未指定",
                    content: "随机推荐10个成语",
                    showCancel: !1
                }), a.setData({
                    data: t.data,
                    hiddendata: !1,
                    hiddenName: !0
                });
            }
        }) : "*" == t ? wx.request({
            url: "https://www.yehamson.xyz/idiom/rand.php",
            data: {},
            success: function(t) {
                console.log(t.data), wx.hideToast(), wx.showModal({
                    title: "未指定",
                    content: "随机推荐10个成语",
                    showCancel: !1
                }), a.setData({
                    data: t.data,
                    hiddendata: !1,
                    hiddenName: !0
                });
            }
        }) : wx.request({
            url: "https://www.yehamson.xyz/idiom/search.php",
            data: {
                value: "%" + e + "%"
            },
            success: function(t) {
                console.log(t.data), null == t.data ? (wx.hideToast(), wx.showModal({
                    title: "出问题",
                    content: "查无此数据",
                    showCancel: !1
                }), a.setData({
                    data: t.data,
                    hiddendata: !0,
                    hiddenName: !1
                })) : (wx.hideToast(), a.setData({
                    data: t.data,
                    hiddendata: !1,
                    hiddenName: !0
                }));
            }
        });
    },
    jump: function(a) {


        var t = a.currentTarget.dataset.name;

        wx.cloud.callFunction({ // 请求msgSecCheck1云函数
          name: 'msgSecCheck1',
          data: {
            msg: t // 需要向云函数msgSecCheck1传入的值
          }
     
        }).then(res => { // 成功时的响应返回结果
          console.log('succ :' + JSON.stringify(res));

          if(res.result.errCode == 87014){

            wx.showToast({
              title: '内容违规',
            })
          }else{

            wx.navigateTo({
                url: "../idiomlist/logs?name=" + t
            });
          }
        }).catch(err => { // 失败时,返回的结果
          console.error('err :' + err);
        })

        
    },
    onShareAppMessage: function(a) {
        return a.from, {
            title: "成语大全",
            path: "/pages/idiom/idiom",
            imageUrl: "http://r.photo.store.qq.com/psc?/V10hbVEX45EgJM/TYYtfnaXgEmfmUb5MQ*YLe63T1WaypskLMkCiD9WCuFhrGsR9dklKgWoRpaJVLuUr*o1CeFZCgUyIiA7S3IY9gQyrr6gRIa*81bGyAwgyCM!/r",
            success: function(a) {}
        };
    },
    onShareTimeline: function(a) {
        return a.from, {
            title: "成语大全",
            imageUrl: "http://r.photo.store.qq.com/psc?/V10hbVEX45EgJM/TYYtfnaXgEmfmUb5MQ*YLe63T1WaypskLMkCiD9WCuFhrGsR9dklKgWoRpaJVLuUr*o1CeFZCgUyIiA7S3IY9gQyrr6gRIa*81bGyAwgyCM!/r",
            success: function(a) {}
        };
    }
});